package com.shixi.shixitraining.shixitraining.ui.tabhome.fragment;

import android.content.Context;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;

import com.shixi.shixitraining.shixitraining.R;
import com.shixi.shixitraining.shixitraining.base.TabhostBaseFragment;
import com.shixi.shixitraining.shixitraining.ui.tabhome.entity.TrainingListDetailBean;
import com.shixi.shixitraining.shixitraining.view.recycleview.BaseAdapter;
import com.shixi.shixitraining.shixitraining.view.recycleview.BaseRecycleHolder;

import java.util.List;

/**
 * Created by shenyan on 2018/8/9.
 */

public class ScheduleFragment extends TabhostBaseFragment {

    private List<TrainingListDetailBean.DataBean.ScheduleBean> scheduleData;

    @Override
    protected int getlayoutId() {
        return R.layout.fragment_schedule;
    }

    @Override
    protected void initPager() {
        initView();
    }

    private void initView() {


        Bundle arguments = getArguments();
        if (arguments!=null){
            TrainingListDetailBean mData = (TrainingListDetailBean) arguments.getSerializable("bean");

            TrainingListDetailBean.DataBean data = mData.getData();
            List<TrainingListDetailBean.DataBean.ScheduleBean> scheduleData = data.getSchedule();


            RecyclerView mRcview = (RecyclerView) mContentView.findViewById(R.id.recview_schedule);
            LinearLayoutManager manager=new LinearLayoutManager(getContext());
            manager.setOrientation(LinearLayoutManager.VERTICAL);
            mRcview.setLayoutManager(manager);

            ScheduleAdapter adapter=new ScheduleAdapter(getContext(),scheduleData);
            mRcview.setAdapter(adapter);
        }




    }

    private  class  ScheduleAdapter  extends BaseAdapter<TrainingListDetailBean.DataBean.ScheduleBean>{

        public ScheduleAdapter(Context context, List<TrainingListDetailBean.DataBean.ScheduleBean> data) {
            super(context, data);
        }

        @Override
        public void convert(BaseRecycleHolder holder, TrainingListDetailBean.DataBean.ScheduleBean item, int position) {
            String title = item.getTitle();
            String content = item.getContent();
            int sort = item.getSort();
            String location = item.getLocation();
            String repast = item.getRepast();
            String traffic = item.getTraffic();
            holder.setText(R.id.tv_schedule_title,item.getTitle());
            holder.setText(R.id.tv_schedule_content,item.getContent());
        }

        @Override
        protected int getLayoutId(int viewType) {
            return R.layout.adapter_schedule;
        }


    }

}
